import request from '@/config/axios'

export interface PostVO {
  id: string
  name: string
  type: string
  dbname: string
  ip: string
  port: number
  param: string
  username: string
  password: string
  zookeeperQuorum: string
  zookeeperPort: string
  hbaseRootdir: string
  kerberosEnable: boolean
  kerberosPrincipal: string
  kerberosKeytabFilepath: string
  ftpProtocol: string
  txtPath: string
  createTime: Date
}

// 查询数据源列表
export const getPostPage = async (params: PageParam) => {
  return await request.get({ url: '/etl/datasource/page', params })
}

// 获取数据源精简信息列表
export const getSimplePostList = async (): Promise<PostVO[]> => {
  return await request.get({ url: '/etl/datasource/simple-list' })
}

// 查询数据源详情
export const getPost = async (id: number) => {
  return await request.get({ url: '/etl/datasource/get?id=' + id })
}

// 新增数据源
export const createPost = async (data: PostVO) => {
  return await request.post({ url: '/etl/datasource/create', data })
}

// 修改数据源
export const updatePost = async (data: PostVO) => {
  return await request.put({ url: '/etl/datasource/update', data })
}

// 删除数据源
export const deletePost = async (id: number) => {
  return await request.delete({ url: '/etl/datasource/delete?id=' + id })
}

// 导出数据源
export const exportPost = async (params) => {
  return await request.download({ url: '/etl/datasource/export', params })
}
